#Lindsay Ergenekan
#ergenekl@onid.oregonstate.edu
#CS311-400
#Homework2- Question3


import urllib2, getopt, sys, os, numbers

def main(argv): 
   url_wanted = sys.argv[1]
   file_name = sys.argv[2]
   url_wanted = "http://" + url_wanted
   
   print url_wanted
   print file_name
 
   try: 
      f = urllib2.urlopen(url_wanted)
      print "downloading " + url_wanted

      new_file = open(file_name, "w")
      new_file.write(f.read())
      new_file.close()

   except urllib2.HTTPError as e: 
      print "HTTP ERROR: " + e.code
   except urllib2.URLError as e: 
      print "URL ERROR: " + e
       


if __name__ == "__main__":
   main(sys.argv[1:])
